package com.tedu.ds.sessionAndMessage.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;
import java.io.*;
import java.net.InetAddress;
import java.net.UnknownHostException;

@Configuration
public class UuidConfig {
    private String uuid;
    public String getUuid(){
        return uuid;
    }
    @PostConstruct
    public void getServerIp() {
        try {
            InetAddress inetAddress = InetAddress.getLocalHost();
            uuid= inetAddress.getHostName();  // 返回主机名
        } catch (UnknownHostException e) {
            throw new RuntimeException("无法获取服务器IP地址", e);
        }
    }

}